/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;
import alcatelparser.modules.*;
/**
 *
 * @author geniuz
 */
public class DefaultParserTag
    implements ITagParser
{

    public DefaultParserTag()
    {
    }

    public void GetToBase(String tagname, String tagcontent){
    
    }
    public void parseTag(int ai[], int i)
    {
    }

    public int getReadBytesCount()
    {
        return _readBytesCount;
    }

    public String getParseIdentityTag()
    {
        return "";
    }

    public void printEmptyTag()
    {
    }

    public boolean containsTag(String s)
    {
        return false;
    }

    public boolean isChoiceTag()
    {
        return false;
    }

    public boolean isTagRequired()
    {
        return false;
    }
    public String GetResult(){
        return "";
    }
    protected final void checkNonDefinedTagLength(int i)
    {
        if(i + _readBytesCount >= _array.length)
        {
            return;
        } else
        {
            if(_array[i + _readBytesCount] == 0);
            if(_array[i + _readBytesCount + 1] == 0);
            return;
        }
    }

    protected final void setStandartLength(int ai[], int i)
    {
        _readBytesCount = 2 + ai[i + 1];
    }

    protected final void setNotParseRecordLength(int ai[], int i)
    {
        int j = ai[i + 1];
        j = j <= 128 ? 1 : 2;
        _readBytesCount = 1 + j;
    }

    public static final String toHex(int i)
    {
        String s = Integer.toHexString(i).toUpperCase();
        s = s.length() != 1 ? s : (new StringBuilder()).append(I.I(548)).append(s).toString();
        return s;
    }

    protected final String getParsedContent()
    {
        int i = _array[_startParsePosition];
        int j = _array[(_startParsePosition + getReadBytesCount()) - 1];
        String p1 = I.I(537), p2= toHex(i), p3=I.I(539), p4=toHex(j), p5=I.I(545);
        
        return (new StringBuilder()).append(p1).append(p2).append(p3).append(p4).append(p5).toString();
    }

    protected final String getTagIdentifyContent(int i, int j)
    {
        int k = _array[i];
        int l = _array[j];
        return (new StringBuilder()).append(I.I(537)).append(toHex(k)).append(I.I(539)).append(toHex(l)).append(I.I(541)).toString();
    }

    protected final String getHexStringContent(int i, int j)
    {
        if(isParametersNotCorrect(i, j))
        {
            //LOG.error((new StringBuilder()).append(I.I(477)).append(i).append(I.I(484)).append(j).append(I.I(494)).toString());
            return I.I(522);
        }
        String s = "";
        for(int k = 0; k < j; k++)
            s = (new StringBuilder()).append(s).append(toHex(_array[i + k])).toString();

        return s;
    }

    protected final String getStringContent(int i, int j)
    {
        if(isParametersNotCorrect(i, j))
        {
            //LOG.error((new StringBuilder()).append(I.I(477)).append(i).append(I.I(484)).append(j).append(I.I(494)).toString());
            return I.I(522);
        }
        String s = "";
        for(int k = 0; k < j; k++)
            s = (new StringBuilder()).append(s).append((char)_array[i + k]).toString();

        return s;
    }

    private boolean isParametersNotCorrect(int i, int j)
    {
        return i + j > _array.length;
    }

    protected final String getDate(int i)
    {
        int j = _array[i];
        String s = "";
        s = j <= 50 ? (new StringBuilder()).append(I.I(474)).append(toHex(j)).toString() : (new StringBuilder()).append(I.I(471)).append(toHex(j)).toString();
        s = (new StringBuilder()).append(toHex(_array[i + 1])).append(I.I(467)).append(s).toString();
        s = (new StringBuilder()).append(toHex(_array[i + 2])).append(I.I(467)).append(s).toString();
        return s;
    }

    protected final String getTime(int i, boolean flag)
    {
        String s = "";
        s = toHex(_array[i]);
        s = (new StringBuilder()).append(s).append(I.I(465)).append(toHex(_array[i + 1])).toString();
        String s1 = flag ? I.I(465) : I.I(467);
        s = (new StringBuilder()).append(s).append(s1).append(toHex(_array[i + 2])).toString();
        if(!flag)
            s = (new StringBuilder()).append(s).append(I.I(469)).append(toHex(_array[i + 3])).toString();
        return s;
    }

    protected final int calculateInnerTagType(int i)
    {
        int j = i >> 5;
        int k = j << 5;
        return i - k;
    }

    protected final boolean isFullForm()
    {
        return Env.getEnv().isFullForm();
    }

    protected final boolean isFieldsDecoding()
    {
        return Env.getEnv().isFieldsDecoding();
    }

    protected final String getReducedTagPropertiesValue(String s)
    {
        return TagProperties.getTagProperties().getReducedTagProperty(s);
    }

    public static final String getTagPropertiesValue(String s)
    {
        return TagProperties.getTagProperties().getProperty(s);
    }

    public static final boolean isTagChecked(String s)
    {
        return true;
        //HashMap hashmap = (HashMap)Env.getEnv().get(I.I(325));
        //JCheckBox jcheckbox = (JCheckBox)hashmap.get(s);
        //if(jcheckbox == null)
        //    return false;
        //else
        //    return jcheckbox.isSelected();
    }

    protected int _startParsePosition;
    protected int _array[];
    protected int _readBytesCount;
    //private static final Logger LOG = Logger.getLogger(com/alcatel/algo/tag/DefaultParserTag);

}
